package com.amoyt.project.exception;

/**
 * @Description: 业务异常实现类（需要捕获的类别）
 */
public class BusinessException extends RuntimeException{
    /**
     * 错误码
     */
    private int errorCode;

    /**
     * 错误信息
     */
    private String errorMsg;
    /**
     * 构造方法1
     * @param errorCode 错误码
     * @param errorMsg 错误信息
     */
    public BusinessException(int errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    /**
     * 构造方法2
     * @param e 基础异常类（可以用枚举类来构造）
     */
    public BusinessException(BaseException e){
        this(e.getErrorCode(), e.getErrorMsg());
    }

    public BusinessException(BaseException e, String errorMsg){
        this(e.getErrorCode(), e.getErrorMsg()+" [具体信息]："+errorMsg);
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
}
